package com.seguriapp.entities;

import java.util.LinkedHashMap;
import java.util.Map;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.NaturalId;

import com.seguriapp.base.BaseEntity;

/**
 * Represents a User x SeguriAppEntity entity.
 * 
 * @author Tania Gonzales(taniadgv@gmail.com)
 */
@Entity
@Table(name = "UserSeguriAppEntity")
public class UserSeguriAppEntity extends BaseEntity {

  private static final long serialVersionUID = -7382829608491394205L;

  @Id
  @GeneratedValue
  private Long id;

  @NaturalId
  @ManyToOne
  @JoinColumn(nullable = false, name = "userId")
  private User user;

  @NaturalId
  @ManyToOne
  @JoinColumn(nullable = false, name = "entityId")
  private SeguriAppEntity entity;

  public Long getId() {
    return id;
  }

  public void setId(final Long id) {
    this.id = id;
  }

  public User getUser() {
    return user;
  }

  public void setUser(final User user) {
    this.user = user;
  }

  public SeguriAppEntity getEntity() {
    return entity;
  }

  public void setEntity(final SeguriAppEntity entity) {
    this.entity = entity;
  }

  public Map<String, Object> toJsonString() {
    final Map<String, Object> map = new LinkedHashMap<String, Object>();
    map.put("id", id);
    map.put("user", user);
    map.put("entity", entity);
    return map;
  }

}
